/**
 * 修改自https://github.com/song940/node-escpos/blob/master/commands.js
 * ESC/POS _ (Constants)
 */
var _ = {
    LF: [10],
    FS: [28],
    FF: [12],
    GS: [29],
    DLE: [16],
    EOT: [4],
    NUL: [0],
    ESC: [27],
    EOL: '\n'
};

/**
 * [FEED_CONTROL_SEQUENCES Feed control sequences]
 * @type {Object}
 */
_.FEED_CONTROL_SEQUENCES = {
    CTL_LF: [10],
    // Print and line feed
    CTL_GLF: [74, 0],
    // Print and feed paper (without spaces between lines)
    CTL_FF: [12],
    // Form feed
    CTL_CR: [13],
    // Carriage return
    CTL_HT: [9],
    // Horizontal tab
    CTL_VT: [11] // Vertical tab
};

_.CHARACTER_SPACING = {
    CS_DEFAULT: [27, 32, 0],
    CS_SET: [27, 32]
};
_.LINE_SPACING = {
    LS_DEFAULT: [27, 50],
    LS_SET: [27, 51]
};

/**
 * [HARDWARE Printer hardware]
 * @type {Object}
 */
_.HARDWARE = {
    HW_INIT: [27, 64],
    // Clear data in buffer and reset modes
    HW_SELECT: [27, 61, 1],
    // Printer select
    HW_RESET: [27, 63, 10, 0] // Reset printer hardware
};

/**
 * [CASH_DRAWER Cash Drawer]
 * @type {Object}
 */
_.CASH_DRAWER = {
    CD_KICK_2: [27, 112, 0],
    // Sends a pulse to pin 2 []
    CD_KICK_5: [27, 112, 1] // Sends a pulse to pin 5 []
};

/**
 * [MARGINS Margins sizes]
 * @type {Object}
 */
_.MARGINS = {
    BOTTOM: [27, 79],
    // Fix bottom size
    LEFT: [27, 108],
    // Fix left size
    RIGHT: [27, 81] // Fix right size
};

/**
 * [PAPER Paper]
 * @type {Object}
 */
_.PAPER = {
    PAPER_FULL_CUT: [29, 86, 0],
    // Full cut paper
    PAPER_PART_CUT: [29, 86, 1],
    // Partial cut paper
    PAPER_CUT_A: [29, 86, 65],
    // Partial cut paper
    PAPER_CUT_B: [29, 86, 66] // Partial cut paper
};

/**
 * [TEXT_FORMAT Text format]
 * @type {Object}
 */
_.TEXT_FORMAT = {
    TXT_NORMAL: [27, 33, 0],
    // Normal text
    TXT_2HEIGHT: [27, 33, 16],
    // Double height text
    TXT_2WIDTH: [27, 33, 32],
    // Double width text
    TXT_4SQUARE: [27, 33, 48],
    // Double width & height text

    TXT_UNDERL_OFF: [27, 45, 0],
    // Underline font OFF
    TXT_UNDERL_ON: [27, 45, 1],
    // Underline font 1-dot ON
    TXT_UNDERL2_ON: [27, 45, 2],
    // Underline font 2-dot ON
    TXT_BOLD_OFF: [27, 69, 0],
    // Bold font OFF
    TXT_BOLD_ON: [27, 69, 1],
    // Bold font ON
    TXT_ITALIC_OFF: [27, 53],
    // Italic font ON
    TXT_ITALIC_ON: [27, 52],
    // Italic font ON

    TXT_FONT_A: [27, 77, 0],
    // Font type A
    TXT_FONT_B: [27, 77, 1],
    // Font type B
    TXT_FONT_C: [27, 77, 2],
    // Font type C

    TXT_ALIGN_LT: [27, 97, 0],
    // Left justification
    TXT_ALIGN_CT: [27, 97, 1],
    // Centering
    TXT_ALIGN_RT: [27, 97, 2] // Right justification
};

/**
 * [BARCODE_FORMAT Barcode format]
 * @type {Object}
 */
_.BARCODE_FORMAT = {
    BARCODE_TXT_OFF: [29, 72, 0],
    // HRI barcode chars OFF
    BARCODE_TXT_ABV: [29, 72, 1],
    // HRI barcode chars above
    BARCODE_TXT_BLW: [29, 72, 2],
    // HRI barcode chars below
    BARCODE_TXT_BTH: [29, 72, 3],
    // HRI barcode chars both above and below

    BARCODE_FONT_A: [29, 102, 0],
    // Font type A for HRI barcode chars
    BARCODE_FONT_B: [29, 102, 1],
    // Font type B for HRI barcode chars

    BARCODE_HEIGHT: function (height) {
        // Barcode Height [1-255]
        return [29, 104, height];
    },
    BARCODE_WIDTH: function (width) {
        // Barcode Width  [2-6]
        return [29, 119, width];
    },
    BARCODE_HEIGHT_DEFAULT: [29, 104, 100],
    // Barcode height default:100
    BARCODE_WIDTH_DEFAULT: [29, 119, 3],
    // Barcode width default:3

    BARCODE_UPC_A: [29, 107, 0],
    // Barcode type UPC-A
    BARCODE_UPC_E: [29, 107, 1],
    // Barcode type UPC-E
    BARCODE_EAN13: [29, 107, 2],
    // Barcode type EAN13
    BARCODE_EAN8: [29, 107, 3],
    // Barcode type EAN8
    BARCODE_CODE39: [29, 107, 4],
    // Barcode type CODE39
    BARCODE_ITF: [29, 107, 5],
    // Barcode type ITF
    BARCODE_NW7: [29, 107, 6],
    // Barcode type NW7
    BARCODE_CODE93: [29, 107, 72],
    // Barcode type CODE93
    BARCODE_CODE128: [29, 107, 73],
    // Barcode type CODE128
    BARCODE_CODEA: [123, 65],
    //code a
    BARCODE_CODEB: [123, 66],
    //code b
    BARCODE_CODEC: [123, 67] //code c
};

/**
 * [IMAGE_FORMAT Image format]
 * @type {Object}
 */
_.IMAGE_FORMAT = {
    S_RASTER_N: [29, 118, 48, 0],
    // Set raster image normal size
    S_RASTER_2W: [29, 118, 48, 1],
    // Set raster image double width
    S_RASTER_2H: [29, 118, 48, 2],
    // Set raster image double height
    S_RASTER_Q: [29, 118, 48, 3] // Set raster image quadruple
};

/**
 * [BITMAP_FORMAT description]
 * @type {Object}
 */
_.BITMAP_FORMAT = {
    BITMAP_S8: [27, 42, 0],
    BITMAP_D8: [27, 42, 1],
    BITMAP_S24: [27, 42, 32],
    BITMAP_D24: [27, 42, 33]
};

/**
 * [GSV0_FORMAT description]
 * @type {Object}
 */
_.GSV0_FORMAT = {
    GSV0_NORMAL: [29, 118, 48, 0],
    GSV0_DW: [29, 118, 48, 1],
    GSV0_DH: [29, 118, 48, 2],
    GSV0_DWDH: [29, 118, 48, 3]
};

/**
 * [BEEP description]
 * @type {string}
 */
_.BEEP = [27, 66]; // Printer Buzzer pre hex

/**
 * [COLOR description]
 * @type {Object}
 */

_.COLOR = {
    0: [27, 114, 0],
    // black
    1: [27, 114, 1] // red
};

/**
 * [exports description]
 * @type {[type]}
 */
module.exports = _;
